<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/9/25
 * Time: 11:39
 */

class History extends ADM_Controller
{
    public function __construct()
    {
        parent::__construct();
    }

    public function index()
    {
        $id = $this->input->get('id');
        $where = ['a.status' => 6];
        if (!empty($id)) {
            $where['a.baseId'] = $id;
        }
        $q = $this->db
            ->select('b.name as baseName, a.*')
            ->join('base as b', 'b.id=a.baseId')
            ->where($where)
            ->get('base_bill_apply as a');
        $rows = $q->result_array();

        if (!empty($rows)) foreach ($rows as &$row) {
            $row['total'] = money_format('%i', $row['total'] / 100);
            $row['refund'] = money_format('%i', $row['refund'] / 100);
            $row['delivery'] = money_format('%i', $row['delivery'] / 100);
            $row['left'] = money_format('%i', $row['left'] / 100);
            $row['fx'] = money_format('%i', $row['fx'] / 100);
        }

        $this->load->view('admin/bill/history.html', [
            'data' => $rows
        ]);
    }
}